package com.lcf.system.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import com.lcf.framework.vo.PageVO;
import com.lcf.system.dto.SysBannerDTO;
import com.lcf.system.query.SysBannerPageQuery;
import com.lcf.system.service.SysBannerService;
import com.lcf.system.vo.SysBannerVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 轮播图(SysBanner)表控制层
 *
 * @author lcf
 * @since 2025-05-07 22:23:23
 */
@Tag(name = "轮播图")
@RestController
@RequestMapping("sysBanner")
public class SysBannerController {
    @Resource
    private SysBannerService sysBannerService;

    /**
     * 新增
     */
    @Operation(summary = "新增轮播图")
    @SaCheckPermission("sys:banner:add")
    @PostMapping
    public void add(@RequestBody @Validated SysBannerDTO dto) {
        sysBannerService.add(dto);
    }

    /**
     * 修改
     */
    @Operation(summary = "修改轮播图")
    @SaCheckPermission("sys:banner:edit")
    @PatchMapping("{id}")
    public void edit(@PathVariable @Schema(description = "轮播图ID") long id,
                     @RequestBody @Validated SysBannerDTO dto) {
        sysBannerService.edit(id, dto);
    }

    /**
     * 删除
     */
    @Operation(summary = "删除轮播图")
    @SaCheckPermission("sys:banner:delete")
    @DeleteMapping("{id}")
    public void delete(@PathVariable @Schema(description = "轮播图ID") long id) {
        sysBannerService.delete(id);
    }

    /**
     * 分页
     */
    @Operation(summary = "轮播图分页")
    @GetMapping("page")
    @SaCheckPermission("sys:banner:page")
    public PageVO<SysBannerVO> page(SysBannerPageQuery query) {
        return sysBannerService.page(query);
    }

    /**
     * 列表
     */
    @Operation(summary = "轮播图列表")
    @GetMapping("list")
    public List<SysBannerVO> listAll() {
        return sysBannerService.listAll();
    }

    /**
     * 详情
     */
    @Operation(summary = "轮播图详情")
    @GetMapping("{id}")
    public SysBannerVO get(@PathVariable @Schema(description = "轮播图ID") long id) {
        return sysBannerService.get(id);
    }
}

